<?php
/**
 * User: Niuxitong
 * Date: 2021/1/7 20:03
 */
namespace app\admin\model;

use think\Db;
use think\Model;

class ServerAddress extends Model{

    // 表名
    protected $table = 'server_address';
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;
    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [

    ];

    public function getHeadingList(){
        $ret = array();
        $groups = Db::name('server_grouping')->select();
        foreach ($groups as $item) {
            $info = array(
                "name" => "index?id=".$item['id'],
                'head' => $item['title']
            );
            $ret[] = $info;
        }
        $null_groups = Db::name('server_address')->where("distinguish is null")->select();
        if ($null_groups){
            $data = array(
                "name" => "index?id=default",
                'head' => "未分配组"
            );
            $ret[] = $data;
        }

        return $ret;
    }

}

